﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using CoolERP_BLL;
using CoolERP_Entities;

namespace CoolERP_Web.WebService
{
    /// <summary>
    /// GetYS 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。
    [System.Web.Script.Services.ScriptService]
    public class GetYS : System.Web.Services.WebService
    {
        [WebMethod]
        public string GetYSByLXBH(string bh)
        {
            string json = string.Empty;
            using (CS_YSBLL cBLL = new CS_YSBLL())
            {
                List<CS_YS> itemList = cBLL.GetList(t => t.YSLXBH == bh);
                foreach (CS_YS item in itemList)
                    json = string.Concat(json, "{id:'", item.BH, "',name:'", item.MC, "'},");
            }
            if (!string.IsNullOrEmpty(json))
                json = "[" + json.Trim(',') + "]";
            return json;
        }
    }
}
